import Vue from 'vue'
import Router from 'vue-router'
// import myfooter from '@/components/footer'
import myheader from '@/components/header'
import index from '@/view/index'
import Login from '@/view/login'
import Detail from '@/view/goods-detail'
import Aboutwe from '@/view/about-finewest'
import ImportGoods from '@/view/import'
import filterGoods from '@/view/filter-goods'
import sweetWine from '@/view/sweet-wine'
import fMa from '@/view/f-ma'
import wineShow from '@/view/wine-show'
import calculate from '@/view/calculate'
import originals from '@/view/originals'
import recommendTop from '@/view/recommend-top'
import test from '@/view/test'
// import originImport from '@/view/origin-import'
// import originalGoods from '@/components/originalGoods'

// 注册路由插件
Vue.use(Router)

// 创建路由实例
const router = new Router({
  mode: 'hash',
  routes: [
    // {path: '/', redirect: '/index'},
    {
      path: '/',
      name: 'Index',
      components: {
        header: myheader,
        goods: index
      },
      meta: {
        name: '优自西方B2B进口平台',
        footer: 0
      }
    },
    {
      path: '/about-finewest',
      name: 'about-finewest',
      components: {
        header: myheader,
        goods: Aboutwe
      },
      meta: {
        name: '了解我们',
        footer: 1
      }
    },
    {
      path: '/login',
      name: 'login',
      meta: {
        name: '登录-优自西方'
      },
      components: {
        index: Login
      }
    },
    {
      path: '/goods-detail',
      name: 'detail',
      meta: {
        name: '商品详情'
      },
      components: {
        index: Detail
      }
    },
    {
      path: '/import',
      name: 'import',
      meta: {
        name: '原产地进口',
        footer: 0
      },
      components: {
        header: myheader,
        index: ImportGoods
      }
    },
    {
      path: '/filter-goods/:goodsId',
      name: 'filter-goods',
      meta: {
        name: '原产地进口-筛选商品',
        footer: 0
      },
      components: {
        header: myheader,
        goods: filterGoods
      }
    },
    {
      path: '/sweet-wine',
      name: 'sweet-wine',
      meta: {
        name: '甜酒榜',
        footer: 0
      },
      components: {
        index: sweetWine
      }
    },
    {
      path: '/f-ma',
      name: 'f-ma',
      meta: {
        name: 'F码',
        footer: 0
      },
      components: {
        header: myheader,
        goods: fMa
      }
    },
    {
      path: '/wine-show',
      name: 'wine-show',
      meta: {
        name: '酒款展示',
        footer: 0
      },
      components: {
        goods: wineShow
      }
    },
    {
      path: '/calculate',
      name: 'calculate',
      meta: {
        name: '计算'
      },
      components: {
        index: calculate
      }
    },
    {
      path: '/originals',
      name: 'originals',
      meta: {
        name: '今日名庄'
      },
      components: {
        index: originals
      }
    },
    {
      path: '/recommend-top',
      name: 'recommend-top',
      meta: {
        name: '酒评家推荐榜'
      },
      components: {
        index: recommendTop
      }
    },
    {
      path: '/test',
      name: 'test',
      meta: {
        name: 'test'
      },
      components: {
        index: test
      }
    }
  ]
})
// afterEach
router.afterEach((to, from) => {
  window.pageYOffset = document.documentElement.scrollTop = document.body.scrollTop = 0
  if (to.children) {
    document.title = to.children.meta.name
  } else {
    document.title = to.meta.name
  }
})

export default router
